<?php

/**
 * This is the model class for table "cciht".
 *
 * The followings are the available columns in table 'cciht':
 * @property integer $id
 * @property integer $user_id
 * @property string $email
 * @property string $name
 * @property string $institution
 * @property string $institution_member
 * @property string $institution_non_member
 * @property string $position
 * @property string $address
 * @property string $city
 * @property string $code
 * @property string $phone
 * @property string $delivery_type
 * @property string $selected_topics
 */
class Cciht extends CActiveRecord
{
  public $nick;
  public $verifyCode;
	/**
	 * Returns the static model of the specified AR class.
	 * @return Cciht the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'cciht';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('email, nick, name, membership_type, number_participants, institution, position, address, city, code, phone, delivery_type, selected_topics', 'required'),
      array('verifyCode', 'CaptchaExtendedValidator', 'allowEmpty'=>!CCaptcha::checkRequirements()),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, user_id, email, name, institution, position, address, city, code, phone, delivery_type, selected_topics', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
      'user' => array(self::BELONGS_TO, 'Users', 'user_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'user_id' => 'User',
			'email' => 'Email',
			'name' => 'Name',
			'institution' => 'Institution',
			'institution_member' => 'Institution Member',
			'institution_non_member' => 'Institution Non Member',
			'position' => 'Position',
			'address' => 'Address',
			'city' => 'City',
			'code' => 'Code',
			'phone' => 'Phone',
			'delivery_type' => 'Delivery Type',
			'selected_topics' => 'Selected Topics',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('email',$this->email,true);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('institution',$this->institution,true);
		$criteria->compare('institution_member',$this->institution_member,true);
		$criteria->compare('institution_non_member',$this->institution_non_member,true);
		$criteria->compare('position',$this->position,true);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('city',$this->city,true);
		$criteria->compare('code',$this->code,true);
		$criteria->compare('phone',$this->phone,true);
		$criteria->compare('delivery_type',$this->delivery_type,true);
		$criteria->compare('selected_topics',$this->selected_topics,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}